import React, { useState } from 'react'
import { Link } from 'react-router-dom'

export default function List() {
    const [list, setList] = useState([
        {
            id: 111,
            title: "标题1"
        },
        {
            id: 222,
            title: "标题2"
        },
        {
            id: 333,
            title: "标题3"
        }
    ])
    return (
        <div>
            <ul>
                {
                    list.map((item) => {
                        return <li key={item.id}>
                            {/* State */}
                            <Link to={{
                                pathname: "/detail",
                                state: {
                                    id: item.id
                                }
                            }}>
                                { item.title }
                            </Link>

                            {/* 任意传值 刷新会丢失 */}
                            {/* <Link to={{
                                pathname: "/detail",
                                qwe: {
                                    id: item.id
                                }
                            }}>
                                {item.title}
                            </Link> */}
                        </li>
                    })
                }
            </ul>
        </div>
    )
}
